package com.tbvtc.agriculturalcreditchainserver2025.vo.Pest;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class getCropPestReportVo implements Serializable {
    @Schema(description = "农作物名称")
    private String cropName;
    @Schema(description = "病害类型")
    private String pestName;
    @Schema(description = "害虫严重性")
    private String pestSeverity;
    @Schema(description = "病害图片")
    private String pestPhotos;
    @Schema(description = "处理方式")
    private String treatmentMethod;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime timestamp;

    @JsonCreator
    public getCropPestReportVo(List<Object> array) {
            this.pestName=array.get(0).toString();
            this.pestSeverity=array.get(1).toString();
            this.pestPhotos=array.get(2).toString();
            this.treatmentMethod=array.get(3).toString();

        this.timestamp = LocalDateTime.ofInstant(
                Instant.ofEpochMilli(((Number) array.get(4)).longValue()),
                ZoneId.of("Asia/Shanghai")
        );

    }

}
